GdkPixbuf *result;
int i, j, k;
+ if (src_x == 0 || src_y == 0)
+ {
+ g_warning ("invalid source position for bilinear gradient\n");
+ return NULL;
+ }
+
p1 = src_pixels + (src_y - 1) * src_rowstride + (src_x - 1) * n_channels;
p2 = p1 + n_channels;
p3 = src_pixels + src_y * src_rowstride + (src_x - 1) * n_channels;
GdkPixbuf *result;
int i, j, k;
+ if (src_x == 0)
+ {
+ g_warning ("invalid source position for horizontal gradient\n");
+ return NULL;
+ }
+
result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, n_channels == 4, 8,
width, height);
dest_rowstride = gdk_pixbuf_get_rowstride (result);
GdkPixbuf *result;
int i, j;
+ if (src_y == 0)
+ {
+ g_warning ("invalid source position for vertical gradient\n");
+ return NULL;
+ }
+
top_pixels = src_pixels + (src_y - 1) * src_rowstride + (src_x) * n_channels;
bottom_pixels = top_pixels + src_rowstride;
gint dest_width,
gint dest_height)
{
- GdkPixbuf *tmp_pixbuf;
+ GdkPixbuf *tmp_pixbuf = NULL;
GdkRectangle rect;
int x_offset, y_offset;
gboolean has_alpha = gdk_pixbuf_get_has_alpha (src);
x_offset = rect.x - dest_x;
y_offset = rect.y - dest_y;
}
- else
+ else if (src_width > 0 && src_height > 0)
{
double x_scale = (double)dest_width / src_width;
double y_scale = (double)dest_height / src_height;
y_offset = 0;
}
- if (mask)
+ if (tmp_pixbuf)
{
- gdk_pixbuf_render_threshold_alpha (tmp_pixbuf, mask,
- x_offset, y_offset,
- rect.x, rect.y,
- rect.width, rect.height,
- 128);
+ if (mask)
+ {
+ gdk_pixbuf_render_threshold_alpha (tmp_pixbuf, mask,
+ x_offset, y_offset,
+ rect.x, rect.y,
+ rect.width, rect.height,
+ 128);
+ }
+
+ gdk_draw_pixbuf (window, NULL, tmp_pixbuf,
+ x_offset, y_offset,
+ rect.x, rect.y,
+ rect.width, rect.height,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+ g_object_unref (tmp_pixbuf);
}
-
- gdk_draw_pixbuf (window, NULL, tmp_pixbuf,
- x_offset, y_offset,
- rect.x, rect.y,
- rect.width, rect.height,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
- g_object_unref (tmp_pixbuf);
}
ThemePixbuf *